<?php

/**
 * This is the model class for table "{{customers}}".
 *
 * The followings are the available columns in table '{{customers}}':
 * @property string $loginname
 * @property string $nick
 * @property string $realname
 * @property integer $flag
 * @property string $jointime
 * @property double $balance
 * @property string $lastlogintime
 * @property string $lastloginip
 * @property string $logintimes
 * @property integer $vip
 * @property integer $credit_level
 */
class Customers extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Customers the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{customers}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('loginname, jointime', 'required'),
			array('flag, vip, credit_level', 'numerical', 'integerOnly'=>true),
			array('balance', 'numerical'),
			array('loginname, nick', 'length', 'max'=>16),
			array('realname', 'length', 'max'=>64),
			array('lastloginip', 'length', 'max'=>24),
			array('logintimes', 'length', 'max'=>10),
			array('lastlogintime', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('loginname, nick, realname, flag, jointime, balance, lastlogintime, lastloginip, logintimes, vip, credit_level', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'loginname' => 'Loginname',
			'nick' => 'Nick',
			'realname' => 'Realname',
			'flag' => 'Flag',
			'jointime' => 'Jointime',
			'balance' => 'Balance',
			'lastlogintime' => 'Lastlogintime',
			'lastloginip' => 'Lastloginip',
			'logintimes' => 'Logintimes',
			'vip' => 'Vip',
			'credit_level' => 'Credit Level',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('loginname',$this->loginname,true);
		$criteria->compare('nick',$this->nick,true);
		$criteria->compare('realname',$this->realname,true);
		$criteria->compare('flag',$this->flag);
		$criteria->compare('jointime',$this->jointime,true);
		$criteria->compare('balance',$this->balance);
		$criteria->compare('lastlogintime',$this->lastlogintime,true);
		$criteria->compare('lastloginip',$this->lastloginip,true);
		$criteria->compare('logintimes',$this->logintimes,true);
		$criteria->compare('vip',$this->vip);
		$criteria->compare('credit_level',$this->credit_level);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}